Skip to content

feat(dotAI): Dot AI LangChain4J - Google Vertex#35241

Draft
ihoffmann-dot wants to merge 12 commits intodot-ai-langchain-amazon-bedrockfrom
dot-ai-langchain-google-vertex
Draft

feat(dotAI): Dot AI LangChain4J - Google Vertex#35241
ihoffmann-dot wants to merge 12 commits intodot-ai-langchain-amazon-bedrockfrom
dot-ai-langchain-google-vertex

Conversation

@ihoffmann-dot
Copy link
Copy Markdown
Member

Summary

Adds Google Vertex AI (Gemini) as a supported chat provider.
Auth is handled via Application Default Credentials — no API key required.

  • Add langchain4j-vertex-ai-gemini dependency (with enforcer exclusions)
  • Add vertex_ai case to LangChain4jModelFactory switch
  • Implement buildVertexAiChatModel using VertexAiGeminiChatModel
  • buildVertexAiEmbeddingModel and buildVertexAiImageModel throw UnsupportedOperationException
  • Add 3 unit tests in LangChain4jModelFactoryTest

Configuration

{
  "chat": {
    "provider": "vertex_ai",
    "projectId": "my-gcp-project",
    "location": "us-central1",
    "model": "gemini-1.5-pro",
    "maxTokens": 8192,
    "temperature": 1.0
  }
}

Notes

  • Authentication uses ADC automatically. The host running dotCMS must have a valid GCP identity configured (gcloud auth application-default login or a service account attached to the instance).
  • No API key is needed or accepted for Vertex AI.
  • Embeddings and image generation are not available for this provider via LangChain4J. Both operations throw UnsupportedOperationException.
  • Two transitive dependencies banned by the project Maven enforcer (org.checkerframework:checker-qual, com.google.android:annotations) are explicitly excluded from the langchain4j-vertex-ai-gemini dependency.

Related Issue

This PR fixes #35183
EPIC: dotAI Multi-Provider Support #33970

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Apr 7, 2026

Claude finished @ihoffmann-dot's task in 2m 43s —— View job


PR Review: feat(dotAI) - Google Vertex AI

  • Gather context and read changed files
  • Review dotCMS/pom.xml changes
  • Review LangChain4jModelFactory.java changes
  • Review ProviderConfig.java changes
  • Review LangChain4jModelFactoryTest.java changes
  • Post review findings

Findings

1. Missing model validation for Vertex AI chat — LangChain4jModelFactory.java:131-135

validateVertexAi checks projectId and location but not model. Both buildVertexAiChatModel and buildVertexAiStreamingChatModel call .modelName(config.model()) directly. If model is null or blank, the builder will propagate a cryptic SDK-level NPE rather than a clean IllegalArgumentException.

The openai case handles this explicitly in the switch:

case "openai":
    requireNonBlank(config.model(), "model", modelType);
    validateOpenAi(config, modelType);

The vertex_ai case should do the same — add requireNonBlank(config.model(), "model", modelType) inside the if ("chat".equals(modelType)) block, and add a corresponding test. Fix this →

2. Inverted condition is hard to follow — LangChain4jModelFactory.java:131

if (!"chat".equals(modelType)) {
    return vertexAiFn.apply(config);  // skips validation; fn throws UnsupportedOperationException
}
validateVertexAi(config, modelType);
return vertexAiFn.apply(config);

The comment says "Throw UnsupportedOperationException before validating config fields" but the code's default path (fall-through after the if) is the chat path. The logic is correct but the negation makes it read backwards. A small refactor to if ("chat".equals(modelType)) as the primary branch makes the intent obvious.

3. No tests for buildStreamingChatModel validation failures

buildChatModel has tests for missing projectId and missing location. buildStreamingChatModel calls the same validateVertexAi code path but has no corresponding tests. Low risk given the shared code path, but the symmetry with other providers is absent. Fix this →

4. pom.xml — version managed by BOM, exclusions look correct

langchain4j-vertex-ai-gemini is covered by the imported langchain4j-bom, so no version is needed. The checker-qual and com.google.android:annotations exclusions are correct for a server-side JVM app. No issue here.

5. ProviderConfig.java — doc-only change, clean.


Summary: Issue 1 (missing model validation) is the only substantive bug — it will surface as a confusing runtime failure rather than a clean validation error. Issues 2 and 3 are minor readability/coverage gaps.

@dotCMS dotCMS deleted a comment from github-actions Bot Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant